package com.zsrt.java.day20161223.wrl.homework;

import org.junit.Test;

public class Work09 {

	/**				h	space前面 	space中间			star
	 * 					   4-h		  2*h-3
	 *     *		1		3			0			1(排除h==1)
	 *    * *		2		2			1			1	1
	 *   *   *		3		1			3			1	1
	 *  *     *		4		0			5			1	1
	 *					   ==h		  5-2*h
	 *   *   *		1		1			3			1	1
	 *    * *		2		2			1			1	1
	 *     *		3		3			0			1(排除h==3)
	 */
	@Test
	public void w09(){
		// 打印上部分
		for(int h1 = 1; h1 <= 4; h1++){
			// 打印前面空格
			for(int sp1 = 1; sp1 <= 4 - h1; sp1++){
				System.out.print(" ");
			}
			// 打印前星号
			System.out.print("*");
			if(1 != h1){
				// 打印中间空格
				for(int s = 1; s <= 2 * h1 - 3; s++){
					System.out.print(" ");
				}
				// 打印后星号
				System.out.print("*");
			}
			System.out.println();
		}

		// 打印下部分
		for(int h2 = 1; h2 <= 3; h2++){
			for(int sp2 = 1; sp2 <= h2; sp2++){
				System.out.print(" ");
			}
			System.out.print("*");
			if(3 != h2){
				for(int s = 1; s <= 5 - 2 * h2; s++){
					System.out.print(" ");
				}
				System.out.print("*");
			}
			System.out.println();
		}
	}
}
